import { request } from '@/utils/request'

import type { ChannelPageReqParams, ChannelReqData, ChannelRes, GuidePageReqParams, GuideReqData, GuideRes } from './model/channel'
import type { EditableReqData, PageResult } from './model/common'

export function getChannelPageList(params: ChannelPageReqParams) {
  return request.get<PageResult<ChannelRes>>({ url: `/v1/guideCompany/page`, params })
}

export function getChannelDetail(id: string) {
  return request.get<ChannelRes>({ url: `/v1/guideCompany`, params: { id } })
}

export function createChannel(data: ChannelReqData) {
  return request.post<ChannelRes>({ url: `/v1/save/guideCompany`, data })
}

export function updateChannel(data: EditableReqData<ChannelReqData>) {
  return request.post<ChannelRes>({ url: `/v1/save/guideCompany`, data })
}

export function deleteChannels(ids: string[]) {
  return request.post<void>({ url: `/v1/delete/guideCompany`, data: ids })
}

export function getChannelGuidePageList(params: GuidePageReqParams) {
  return request.get<PageResult<GuideRes>>({ url: `/v1/guide/page`, params })
}

export function getChannelGuideDetail(id: string) {
  return request.get<GuideRes>({ url: `/v1/guide`, params: { id } })
}

export function createChannelGuide(data: GuideReqData) {
  return request.post<void>({ url: `/v1/save/guide`, data })
}

export function updateChannelGuide(data: EditableReqData<GuideReqData>) {
  return request.post<void>({ url: `/v1/save/guide`, data })
}

export function deleteChannelGuides(ids: string[]) {
  return request.post<void>({ url: `/v1/delete/guide`, data: ids })
}
